package com.rd.student.jiaji.class1.wangyufang.day0809;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int j = scanner.nextInt();
        int j1 = scanner.nextInt();
        int j2 = scanner.nextInt();
        int j3 = scanner.nextInt();
        System.out.print("加密前：");
        System.out.print(j);
        System.out.print(j1);
        System.out.print(j2);
        System.out.println(j3);

        int[] i = new int[4];
        i[0] = (j + 5) % 10;
        i[1] = (j1 + 5) % 10;
        i[2] = (j2 + 5) % 10;
        i[3] = (j3 + 5) % 10;

        int i1 = i[0] + i[3];
        i[0] = i1 - i[0];
        i[3] = i1 - i[0];
        int i2 = i[1] + i[2];
        i[1] = i2 - i[1];
        i[2] = i2 - i[1];

        System.out.print("加密后：");
        System.out.print(i[0]);
        System.out.print(i[1]);
        System.out.print(i[2]);
        System.out.println(i[3]);

        int i3 = i[0] + i[3];
        i[0] = i3 - i[0];
        i[3] = i3 - i[0];
        int i4 = i[1] + i[2];
        i[1] = i4 - i[1];
        i[2] = i4 - i[1];

        for (int k = 0; k < i.length; k++) {
           if (i[k]<10&&i[k]>5){
               i[k] = i[k] -5;
           }else{
               i[k] = i[k]+5;
           }
        }
        System.out.print("解密后：");
        System.out.print(i[0]);
        System.out.print(i[1]);
        System.out.print(i[2]);
        System.out.println(i[3]);
    }
}
